<div class="modal-header">
  <button type="button" class="close" data-dismiss="modal" aria-label="关闭"><span aria-hidden="true">&times;</span></button>
  <h4 class="modal-title" id="extension-modal-label">注册环信账号</h4>
</div>
<div class="modal-body editor-body-sm">
	<form class="form-horizontal form-editor form-editor-notify">
		<div class="row">
			<div class="col-sm-4">
				<div class="form-group">
					<label class="col-sm-3 control-label required" for="type">用户类型</label>
					<div class="col-sm-9">
						<select name="type" id="type" class="chosen-select">
							<option value="parents">学员家长</option>
							<option value="teacher">机构老师</option>
						</select>
					</div>
				</div>
			</div>
			
			<div class="col-sm-4">
				<div class="form-group">
					<label class="col-sm-3 control-label required" for="mobile">手机</label>
					<div class="col-sm-9">
						<input name="mobile" id="mobile" class="form-control" required="required">
					</div>
				</div>
			</div>
		</div>
		
		<div class="widget-footer editor-footer-sm">
			<button type="button" class="btn btn-danger  btn-sm" data-toggle="tooltip" data-placement="top" title="取消" onclick="handlerModel(this, 'cancel');">
				<i class="glyphicon glyphicon-remove"></i>
			</button>
			<button type="button" class="btn btn-primary btn-sm" data-toggle="tooltip" data-placement="top" title="注册" onclick="handlerModel(this, 'submit');">
				<i class="glyphicon glyphicon-ok"></i>
			</button>
		</div>
	</form>
</div>

<script type="text/javascript">
<!--
	
	function afterRegister(){
		require(['jquery.plugin.form'],function(form){
			form.chosen("#type");
		});
	}
	
	function handlerModel(button, key){
		switch (key) {
			case "cancel":
				jQuery("#common-modal").modal("hide");
			break;
			case "submit":
				var type = jQuery("#type").val();
				var mobile = jQuery("#mobile").val();
				if(!mobile || mobile.length < 11){
					jQuery.message.warning("手机未填写，或格式不正确！");
				}else{
					var $btn = $(button).data("loadingText","正在提交...").button('loading').tooltip('destroy');
										
					jQuery.ajaxsend({
						url:"/miwawa/system/easemob/register",
						data:{
							"type": type,
							"mobile": mobile
						},
						success:function(data){
							if(data && data.success){
								jQuery.message.warning(data.success);
								if(data.success == '环信帐户注册成功！') {
									jQuery("#easemob-modal").modal("hide");
									jQuery("#table-easemob").bootstrapTable("refresh");
								}
							}
							$btn.button('reset').tooltip();
						}
					});
				}
			break;
		}
	}
//-->
</script>